﻿<%@ Page UICulture="zh-CN" Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeBehind="AdmParcelCombine.aspx.cs" Inherits="FastShip88.Admin.AdmParcelCombine" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="server">

		<div id="content_one_col">
		   
            <asp:Label ID="Label1" runat="server" Text="下面列出所有需要合并的包裹：" CssClass="gv_prompt"></asp:Label>&nbsp;
            <br /><br />
            <div id="div_results" runat="server" visible="false" >
                <asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="False" 
                    DataKeyNames="Id" DataSourceID="LinqDataSource1" Width="780px"  
                    EmptyDataText="没有数据！" 
                    onselectedindexchanged="gvResults_SelectedIndexChanged" CellPadding="5" 
                    AllowPaging="True" PageSize="5" 
                    onpageindexchanging="gvResults_PageIndexChanging"  >
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="UserName" HeaderText="用户名">
                        <ItemStyle Width="80px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Id" HeaderText="系统编号" ReadOnly="True" >
                         <ItemStyle Width="80px" />
                         </asp:BoundField>
                       <asp:BoundField DataField="ParcelNo" HeaderText="运单号" ReadOnly="True" 
                            SortExpression="ParcelNo"  Visible="False">
                        <ItemStyle Width="160px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Description" HeaderText="描述" ReadOnly="True" 
                            SortExpression="Description">
                        <ItemStyle Width="340px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Weight" HeaderText="重量" ReadOnly="True" 
                            SortExpression="Weight" >
                        <ItemStyle Width="80px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="ArriveDate" HeaderText="合并申请日期" ReadOnly="True" 
                            SortExpression="ArriveDate" DataFormatString="{0:d}" >
                        <ItemStyle Width="100px" />
                        </asp:BoundField>
                    </Columns>
                    <SelectedRowStyle BackColor="#669999"  />
                    <HeaderStyle BackColor="#999999" ForeColor="White" />
                </asp:GridView>
                <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                    ContextTypeName="FastShip88.DBAccess.UsersDataContext" 
                    Select="new (ParcelNo, Description, ShopInfo, Weight, ArriveDate, Id, UserId, ShopId)" 
                    TableName="ParcelInfos">
                </asp:LinqDataSource>
                <hr />
            </div>
            
                   <div id="div_selected" runat="server" visible="false" >
                
             <asp:Label ID="lblSplit" runat="server" Text="下面列出选中合并包裹的详细资料："  CssClass="gv_prompt" ></asp:Label>&nbsp;<br /><br />          
                <asp:FormView ID="fvSelected" runat="server" DataKeyNames="Id" 
                    DataSourceID="SqlDataSource1" DefaultMode="Edit" Width="707px" 
                    onprerender="fvSelected_PreRender" onitemcommand="fvSelected_ItemCommand">
                    <EditItemTemplate>
                        
                       <table style="width: 750px;" cellpadding="5">
                          
                           <tr>
                                <td>
                                    &nbsp;描述：
                                </td>
                                <td colspan=2 >
                                    &nbsp;<asp:TextBox ID="txtDescription" runat="server" Width="500px" Height="36px" Text='<%# Bind("Description") %>' ></asp:TextBox>
                                </td>
                                
                            </tr>
                            
                             <tr>
                                <td>
                                    &nbsp;重量：
                                </td>
                                <td>
                                    &nbsp;<asp:TextBox ID="txtWeight" runat="server" Text='<%# Bind("Weight") %>'></asp:TextBox><font color="#ff0000">*</font><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                                        ErrorMessage="请输入重量" ControlToValidate = "txtWeight"  ></asp:RequiredFieldValidator>
                                </td>
                                <td>
                                    &nbsp;单位为磅（pound）。
                                </td>
                            </tr>
                               

                           <tr>
                            <td>
                                &nbsp;体积：
                            </td>
                            <td>
                                &nbsp;长<asp:TextBox ID="txtLength" runat="server" Width="40px" Text='<%# Bind("Length") %>'></asp:TextBox>
                                  &nbsp;宽<asp:TextBox ID="txtWidth" runat="server" Width="40px" Text='<%# Bind("Width") %>'></asp:TextBox>
                                &nbsp;高<asp:TextBox ID="txtHeight" runat="server" Width="40px" Text='<%# Bind("Height") %>' ></asp:TextBox>
                              
                            </td>
                            <td>
                                &nbsp;单位为英寸（inch）。
                            </td>
                        </tr>
                        
                            <tr>
                                <td>
                                    &nbsp;海关申报全额： </td><td colspan=2 >
                                    &nbsp;<asp:TextBox ID="txtDeclareValue" runat="server" Width="100px" Text='<%# Bind("DeclareValue") %>' ></asp:TextBox>元（人民币）</td>
                           </tr>      
                           <tr>
                                <td>
                                    &nbsp;补缴关税金额<font color="red">*</font>： </td><td colspan=2 >
                                    &nbsp;<asp:TextBox ID="txtTariff" runat="server" Width="100px" Text='<%# Bind("Tariff") %>' ></asp:TextBox>元（人民币）<asp:RequiredFieldValidator 
                                        ID="RequiredFieldValidator2" runat="server" 
                                        ErrorMessage="请填入关税金额" ControlToValidate="txtTariff"></asp:RequiredFieldValidator>
                                </td>
                           </tr>  
                 
                      
                        <tr>
                            <td>
                                &nbsp;系统备注：
                            </td>
                            <td colspan=2>
                                &nbsp;<asp:TextBox ID="txtMemo" runat="server" Height="36px" Width="500px" Text='<%# Bind("Memo") %>'></asp:TextBox>
                                
                                <asp:Label ID="lblCombineDate" runat="server" Text='<%# Bind("CombineDate") %>' Visible ="false" ></asp:Label>
                                <asp:Label ID="lblCombineUserId" runat="server" Text='<%# Bind("CombineUserId") %>' Visible ="false" ></asp:Label>
                            </td>
                            
                        
                    </table>
                                        
                                <asp:Button ID="btnSplitComplete" runat="server" Text="合并完成" CommandName="Update"  CommandArgument="Complete" /> 
                                <asp:Button ID="btnSplitCancel" runat="server" Text="合并失败" CommandName="Update"  CommandArgument="Fail" CausesValidation="False" /> 
                                         
                                <asp:Button ID="btnUpdate" runat="server" Text="保存" CommandName="Update" /> &nbsp;
                                <asp:Button ID="btnCancel" runat="server" Text="取消" CommandName="Cancel"  Visible ="false"  />


               </EditItemTemplate>

                
           </asp:FormView>
                                
              
      <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:FastShip88ConnectionString %>" 
                    SelectCommand="SELECT * FROM [ParcelInfos] WHERE ([Id] = @Id)" 
                    
                    UpdateCommand="UPDATE [ParcelInfos] SET [Description] = @Description, [Weight] = @Weight, [Length] = @Length, [Width] = @Width, [Height] = @Height,  [DeclareValue] = @DeclareValue, [Memo] = @Memo, [Tariff] = @Tariff, [CombineDate] = @CombineDate, [CombineUserId] = @CombineUserId WHERE [Id] = @Id" 
                    onupdated="SqlDataSource1_Updated" onupdating="SqlDataSource1_Updating" 
                    >
       <SelectParameters>
           <asp:ControlParameter ControlID="gvResults" Name="Id" 
               PropertyName="SelectedValue" Type="Int32" />
       </SelectParameters>
       <DeleteParameters>
           <asp:Parameter Name="Id" Type="Int32" />
       </DeleteParameters>
       <UpdateParameters>
           <asp:Parameter Name="Description" Type="String" />
           <asp:Parameter Name="Weight" Type="Double" />
           <asp:Parameter Name="Length" Type="Int32" />
           <asp:Parameter Name="Width" Type="Int32" />
           <asp:Parameter Name="Height" Type="Int32" />
           <asp:Parameter Name="DeclareValue" Type="Decimal" />
           <asp:Parameter Name="Memo" Type="String" />
           <asp:Parameter Name="Tariff" Type="Decimal" />
           <asp:Parameter Name="CombineDate" Type="DateTime" />
           <asp:Parameter Name="CombineUserId" Type="Int32" />
           <asp:Parameter Name="Id" Type="Int32" />
       </UpdateParameters>
     
       </asp:SqlDataSource>             
            </div>
            
              <asp:Label ID="lblError" runat="server" Text="出现错误" Font-Bold="True" 
              Font-Size="Medium" ForeColor="#CC0000" Height="30px" Visible="False" 
              Width="500px"></asp:Label>
                
            <asp:Label ID="lblSuccess" runat="server" Text="操作已成功" Font-Bold="True" 
              Font-Size="Medium" ForeColor= "Green" Height="30px" Visible="False" 
              Width="500px"></asp:Label>
         
            
            <div id="div_sub" runat="server" visible="false" >
            <br /><br />
             <asp:Label ID="Label3" runat="server" Text="下面列出合并包裹包含的到站包裹：" CssClass="gv_prompt"></asp:Label>&nbsp;
            <br /><br />
     
                <asp:GridView ID="gvParcel" runat="server" AutoGenerateColumns="False" 
                    DataKeyNames="Id" DataSourceID="LinqDataSource3" Width="840px"  
                    EmptyDataText="没有包含到站包裹。" 
                    onselectedindexchanged="gvResults_SelectedIndexChanged" CellPadding="5" PageSize="5" 
                    onpageindexchanging="gvResults_PageIndexChanging"  >
                    <Columns>
                        <asp:BoundField DataField="Id" HeaderText="系统编号" ReadOnly="True" >
                         <ItemStyle Width="80px" />
                         </asp:BoundField>
                       <asp:BoundField DataField="ParcelNo" HeaderText="运单号" ReadOnly="True" 
                            SortExpression="ParcelNo"  >
                        <ItemStyle Width="160px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="ShopName" HeaderText="商家" ReadOnly="True" >
                        <ItemStyle Width="120px"    />
                        </asp:BoundField>
                        <asp:BoundField DataField="Description" HeaderText="描述" ReadOnly="True" 
                            SortExpression="Description">
                        <ItemStyle Width="240px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Weight" HeaderText="重量" ReadOnly="True" 
                            SortExpression="Weight" >
                        <ItemStyle Width="80px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="ArriveDate" HeaderText="到达日期" ReadOnly="True" 
                            SortExpression="ArriveDate" DataFormatString="{0:d}" Visible="False">
                        <ItemStyle Width="100px" />
                        </asp:BoundField>
                    </Columns>
                    <SelectedRowStyle BackColor="#669999"  />
                    <HeaderStyle BackColor="#999999" ForeColor="White" />
                </asp:GridView>
                <asp:LinqDataSource ID="LinqDataSource3" runat="server" 
                    ContextTypeName="FastShip88.DBAccess.UsersDataContext" 
                    TableName="ParcelInfos" Where="ToId == @ToId" 
                    Select="new (Id, ParcelNo, UserId, Description, Weight, Length, Width, Height, ShopId, ShopInfo, UserInfo, StatusId, Memo, ToId, ParcelStatus)">
                    <WhereParameters>
                        <asp:ControlParameter ControlID="gvResults" Name="ToId" 
                            PropertyName="SelectedValue" Type="Int32" />
                    </WhereParameters>
                </asp:LinqDataSource>
               <br />
            <asp:Label ID="Label2" runat="server" Text="下面列出合并包裹包含的子包裹："   CssClass="gv_prompt"></asp:Label>&nbsp;<br /><br />
                <asp:GridView ID="gvSub" runat="server" AutoGenerateColumns="False"  EmptyDataText="没有包含子包裹。" 
                    Width="840px" DataKeyNames="Id" DataSourceID="LinqDataSource2"    PageSize="5">
                    <Columns>
                        <asp:BoundField DataField="id" HeaderText="系统编号">
                        <ItemStyle Width="60px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Description" HeaderText="描述">
                        <ItemStyle Width="420px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Weight" HeaderText="重量">
                        <ItemStyle Width="60px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="CreateDate" HeaderText="拆分日期" 
                            DataFormatString="{0:d}">
                        <ItemStyle Width="80px" />
                        </asp:BoundField>
                        <asp:BoundField DataField="FinishDate" HeaderText="完成日期" 
                            DataFormatString="{0:d}">
                        <ItemStyle Width="80px" />
                        </asp:BoundField>
                        <asp:CheckBoxField DataField="IsCancel" HeaderText="是否取消" ReadOnly="True">
                        <ItemStyle Width="60px" />
                        </asp:CheckBoxField>
                    </Columns>
                <SelectedRowStyle BackColor="#669999"  />
                <HeaderStyle BackColor="#999999" ForeColor="White" />
                </asp:GridView>
            
                <asp:LinqDataSource ID="LinqDataSource2" runat="server" 
                    ContextTypeName="FastShip88.DBAccess.UsersDataContext" 
                    TableName="SubParcels" 
                    EnableDelete="True" Where="ToId == @ToId">
                    <WhereParameters>
                        <asp:ControlParameter ControlID="gvResults" Name="ToId" 
                            PropertyName="SelectedValue" Type="Int32" />
                        <%--<asp:Parameter DefaultValue="null" Name="ToId" Type="Int32" />--%>
                    </WhereParameters>
                </asp:LinqDataSource>
                <hr />
            
     
            </div>
</asp:Content>
